<?php


  // Pull in the required classes
  require(DIR_WS_CLASSES . "smsnotify.php");

  $sms_destination = SMS_API_DESTINATION; 

  $sms_message = SMS_API_MESSAGE;
  $sms_message .= ": " . $order->customer['lastname'] . " (" . $order->info['currency'] . " " . $order->info['total'] . ")";
     
  $sms_error_to_name = STORE_OWNER;
  $sms_error_to = STORE_OWNER_EMAIL_ADDRESS;
  $sms_from_email_name = STORE_NAME;
  $sms_from_email_address = STORE_OWNER_EMAIL_ADDRESS;
  
  // You can change these to suit
  $sms_error_subject = "Error sending Order Notification by SMS";
  $sms_email_text = "An error occurred whilst attempting to notify the shop owner of a new order by SMS. The response code " .
                    "given by the SMS gateway was:\n\n";
  
  $sms_email_text_extra = "\n\nPlease refer to http://www.joomla-host.co.za/ for more information";


  // Create notification object
  $sms_orderid = $insert_id; // populated by checkout_process.php
  $sms_reference = $order->customer['lastname'];
  $smsNotifyObj = new smsNotify($sms_destination, $sms_message,$sms_orderid,$sms_reference);
  
  // Send notification
  if(!$smsNotifyObj->SendSmsMessage()) {
      // If it fails, we'll send a notification by email to the relevant party
      $sms_email_text .= $smsNotifyObj->SMS_Response_Data . ": " . $smsNotifyObj->ErrorMessage . $sms_email_text_extra;
      tep_mail($sms_error_to_name, $sms_error_to, $sms_error_subject, $sms_email_text, $sms_from_email_name, $sms_from_email_address);
  }
  
  // End of script
?>
